package com.gx.telephonedemo2.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import com.android.tu.loadingdialog.LoadingDailog;

import org.greenrobot.eventbus.EventBus;

/**
 * Description:
 * Author: GX
 * CreateDate: 2019/8/20 10:48
 * UpdateUser: GX
 * UpdateDate: 2019/8/20 10:48
 * UpdateRemark:
 * Version: 1.0
 */
public abstract class BaseActivity extends AppCompatActivity {

    private LoadingDailog loadingDialog;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    protected void onStart() {
        super.onStart();
//        EventBus.getDefault().register(this);
    }

    @Override
    protected void onStop() {
        super.onStop();
//        EventBus.getDefault().unregister(this);
    }

    /*显示加载提示框*/
    public void showLoadingDialog() {
        if (loadingDialog != null && loadingDialog.isShowing()) {
            return;
        }
        LoadingDailog.Builder loadBuilder = new LoadingDailog.Builder(this)
                .setMessage("加载中...")
                .setCancelable(true)
                .setCancelOutside(false);
        loadingDialog = loadBuilder.create();
        loadingDialog.show();
    }

    /*隐藏加载提示框*/
    public void hideLoadingDialog() {
        if (loadingDialog != null && loadingDialog.isShowing()) {
            loadingDialog.dismiss();
        }
    }
}
